import request from '@/utils/request.js'
// 文章分类列表接口
const getCateListAPI = () => {
  return request.get('/my/cate/list')
}

// 新增文章分类
const addCateAPI = obj => {
  return request.post('/my/cate/add', obj)
}

// 根据 id 删除文章分类
const delCateAPI = (id) => {
  return request({
    method: 'delete',
    url: '/my/cate/del',
    params: {
      id
    }
  })
}

// 根据 id 获取文章分类数据
// const getCateDataAPI = obj => {
//   return request.put('/my/cate/info', obj)
// }
const getCateDataAPI = (id) => {
  return request({
    method: 'get',
    url: '/my/cate/info',
    params: {
      id
    }
  })
}
// 根据 id 更新文章分类数据
const updataArtAPI = (editForm) => {
  return request({
    method: 'put',
    url: '/my/cate/info',
    data: editForm
  })
}

// 发布文章的接口函数
// const pubArticleAPI = obj => {
//   return request.post('/my/article/add', obj)
// }
const pubArticleAPI = (formData) => {
  return request({
    method: 'post',
    url: '/my/article/add',
    data: formData
  })
}

// 获取文章列表的接口
const getArtListAPI = (q) => {
  return request({
    method: 'get',
    url: '/my/article/list',
    params: q
  })
}

// 获取文章详情的接口
const getArtDetailAPI = (id) => {
  return request({
    method: 'get',
    url: '/my/article/info',
    params: {
      id
    }
  })
}

// 删除文章接口
const delArtAPI = (id) => {
  return request({
    method: 'delete',
    url: '/my/article/info',
    params: {
      id
    }
  })
}
export {
  getCateListAPI,
  addCateAPI,
  getCateDataAPI,
  updataArtAPI,
  delCateAPI,
  pubArticleAPI,
  getArtListAPI,
  getArtDetailAPI,
  delArtAPI
}
